"""
数据持久层对象
@Time: 2021/1/27 22:20
@Author:
@File: mysql_po.py
"""
from sqlalchemy import Column, ForeignKey, Integer, String, BigInteger
from sqlalchemy.orm import relationship

from mysql_connect import Base


class User(Base):
    __tablename__ = 'users'

    username = Column(String(255), primary_key=True, nullable=False, unique=True, index=True)
    hashed_password = Column(String(255), nullable=False)
    name = Column(String(255))
    phone = Column(String(255), nullable=False)
    student_name = Column(String(255))


class Volunteer(Base):
    __tablename__ = 'tb_volunteer'

    id = Column(BigInteger, primary_key=True, autoincrement=True, index=True)
    name = Column(String(11), default='')
    university_code = Column(String(11), default='')
    province = Column(String(20), default='')
    city = Column(String(20), default='')
    address = Column(String(101), default='')
    is_undergraduate_school = Column(Integer, default=0)
    is_junior_school = Column(Integer, default=0)
    is_985 = Column(Integer, default=0)
    is_211 = Column(Integer, default=0)
    is_public = Column(Integer, default=0)
    is_private = Column(Integer, default=0)
    category = Column(String(11), default='')
    pic_link = Column(String(601), default='')
    employment_rate = Column(Integer, default=0)
    score = Column(Integer, default=0)
    professional_name = Column(String(255), default='')
    lowest_score = Column(Integer, default=0)


class Province(Base):
    __tablename__ = 'province'

    id = Column(Integer, primary_key=True, unique=True, index=True, autoincrement=True)
    name = Column(String(255))


if __name__ == '__main__':
    """
    一键生成数据库表
    """
    from mysql_connect import engine

    Base.metadata.create_all(engine)